package pucp.carpooling.model;

import java.util.Arrays;

import org.json.JSONException;
import org.json.JSONObject;
public class Coordenadas {
	private LngLat start;
	private LngLat end;
	private String[] waypoints;

	public Coordenadas (LngLat start,LngLat end, String[] waypoints) {
		this.end=end;
		this.start=start;
		this.waypoints=waypoints;
	}
	public LngLat getStart() {
		return start;
	}

	public void setStart(LngLat start) {
		this.start = start;
	}

	public LngLat getEnd() {
		return end;
	}

	public void setEnd(LngLat end) {
		this.end = end;
	}

	public String[] getWaypoints() {
		return waypoints;
	}

	public void setWaypoints(String[] waypoints) {
		this.waypoints = waypoints;
	}

	public String coordToJSon(Coordenadas coords) {
		try {
			JSONObject jsonCoords = new JSONObject();

			JSONObject jsonStart = new JSONObject();
			jsonStart.put("lng", coords.getStart().getLng());
			jsonStart.put("lat", coords.getStart().getLat());
			
			
			JSONObject jsonEnd = new JSONObject();
			jsonEnd.put("lng", coords.getEnd().getLng());
			jsonEnd.put("lat", coords.getEnd().getLat());
		
			
			Double[] arreglo = new Double[0];
			jsonCoords.put("start", jsonStart);
			jsonCoords.put("end", jsonEnd);
			jsonCoords.put("waypoints", Arrays.toString(arreglo));
			return jsonCoords.toString();
		} catch (JSONException e) {

		}

		return null;

	}

}